﻿
 
 
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
 
<title>jb-aptech毕业设计项目</TITLE>
<meta name="renderer" content="ie-comp">
	<link href="../../css/style.css" rel="stylesheet" type="text/css">
	<link rel="stylesheet" href="../../css/menu.css">

	<script src="../../script/jquery-3.3.1.min.js"></script>
	<script src="../../script/common.js"></script>
	<script src="../../../js/bootstrap.min.js"></script>
	<script src="../../../js/vue.js"></script>
</head>
  <body>
  <div id="query">
    <div class="page_title">权限管理 > 用户管理 > 系统用户管理</div>
    <input type="hidden" name="method" value="userForward">
    	<div class="button_bar">
	   		<button class="common_button" onclick="help('');">帮助</button>
	   		<button class="common_button" onclick="to('add.html');">新建</button>
			<button class="common_button" @click="bylike(1)">查询</button>
	   	</div>
	   	<table class="query_form_table">
	   		<tr>
	   			<th>
	   				用户名
	   			</th>
	   			<td>
	   				<input type="text" v-model="might.usr_name" size="20">
	   			</td>
	   			<th>
	   				是否禁用
	   			</th>
	   			<td>
	   				<select v-model="might.usr_flag">
						<option value="">全部</option>
	   					<option value=1>正常</option>
	   					<option value=2>禁用</option></select>
	   			</td>
	   		</tr>
	   	</table>
	   	<br/>
	   	<table class="data_list_table">
	   		<tr>
	   			<th>编号</th>
	   			<th>用户名</th>
	   			<th>角色</th>
	   			<th>状态</th>
	   			<th>操作</th>
	   		</tr>
	   		<tr v-for="l in lists">
	   			<td class="list_data_text">{{l.usr_id}}</td>
	   			<td class="list_data_text">{{l.usr_name}}</td>
	   			<td class="list_data_text">{{l.role_name}}<span v-if="l.role_name==null">未指派</span></td>
	   			<td class="list_data_text">
					<span v-if="l.usr_flag==1">正常</span>
					<span v-if="l.usr_flag==2">禁止</span>
	   			</td>
	   			<td class="list_data_op">
	   					<img @click="go(l.usr_id,'edit.html')" title="编辑" src="../../images/bt_edit.gif" class="op_button" />
	   					<img @click="go(l.usr_id,'dispatch.html')" title="指派" src="../../images/bt_linkman.gif" class="op_button" />
	   					<img @click="go(l.usr_id,'detail.html')" title="查看" src="../../images/bt_deal.gif" class="op_button" />
	   					<img @click="dl(l.usr_id)" title="删除" src="../../images/bt_del.gif" class="op_button" />
	   			</td>
	   		</tr>
	   		<tr>
		<th colspan="7" class="pager">
			<div>
			共{{pageInfo.total}}条记录 每页<input value="10" size="2" v-model="pageInfo.pageSize"/>条
			第<input value="1" size="2" v-model="pageInfo.pageNum"/>页/共{{pageInfo.pages}}页
			<a href="javascrip:;" @click="bylike(1)"> 第一页</a>
			<a href="javascrip:;" @click="bylike(pageInfo.pageNum-1)" :class="{'hidden':!pageInfo.hasPreviousPage}">上一页</a>
			<a href="javascrip:;" @click="bylike(pageInfo.pageNum+1)" :class="{'hidden':!pageInfo.hasNextPage}">下一页</a>
			<a href="javascrip:;" @click="bylike(pageInfo.pages)">最后一页</a>
			转到<input style="width: 20px"  v-model="pageInfo.pageNum"/>页
			<button  type="button" @click="bylike(pageInfo.pageNum)">GO</button>
		</div>
		</th>
	</tr>
	   	</table>
  </div>
  </body>
<script>
	var app = new Vue({
		el:'#query',
		data:{
            lists:[],
            pageInfo:'',
            might:{
                usr_name:'',
                usr_flag:'',
                startPage:'',
                PageSize:''
            },
		},
		methods:{
			bylike(page){
                if(page<=0){
                    page=1;
                }
                if(page>=this.pageInfo.pages){
                    page=this.pageInfo.pages;
                }
                this.might.startPage=page;
                this.might.PageSize=this.pageInfo.pageSize;
                $.getJSON("/selectSysUserBylike",this.might,function (json) {
                    app.lists=json.data.pageInfo.list;
                    app.pageInfo=json.data.pageInfo;
                });
			},
			dl(id){
				let uid = sessionStorage.getItem("usr_id");
				if(uid==id){
				    alert(id)
				    alert(uid)
				    alert("不能删除当前登陆用户!!!");
				    return;
				}
			    $.getJSON("/delSysUserById/"+id,function (json) {
					if(json.code==200){
					    alert("删除成功！");
                        $.getJSON("/selectSysUserBylike",this.might,function (json) {
                            app.lists=json.data.pageInfo.list;
                            app.pageInfo=json.data.pageInfo;
                        });
					}else{
					    alert("服务器异常！");
					}
                });
			},
            go(id,value){
				sessionStorage.setItem("id",id);
				location=value;
			}
		},
		created(){
			$.getJSON("/selectSysUserBylike",function (json) {
                app.lists=json.data.pageInfo.list;
                app.pageInfo=json.data.pageInfo;
            });
		}
	});
</script>
</html>
